package com.ibangnuo.manage.controller.commission;

import com.ibangnuo.api.commission.CommissionControllerApi;
import com.ibangnuo.framework.domain.CommissionMonth;
import com.ibangnuo.framework.domain.request.commission.CommissionCommercialDayRequest;
import com.ibangnuo.framework.domain.request.commission.CommissionRequest;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.commission.CommissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: wwy
 * @Date: 2020-03-12 17:49
 */
@RestController
@RequestMapping("/commission")
public class CommissionController implements CommissionControllerApi {

    @Autowired
    private CommissionService commissionService;

    /**
     * 下级代理商月佣金查看
     * @param page
     * @param size
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findList/{page}/{size}")
    @Override
    public QueryResponseResult findList(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody CommissionRequest commissionRequest) {
        return commissionService.findList(page,size,commissionRequest);
    }

    /**
     * 当前登录人代理商日佣金
     * @param page
     * @param size
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findDayList/{page}/{size}")
    @Override
    public QueryResponseResult findDayList(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody CommissionRequest commissionRequest) {
        return commissionService.findDayList(page,size,commissionRequest);
    }

    /**
     * 当前登录人日佣金直属商户佣金统计
     * @param map
     * @return
     */
    @PostMapping("/countTimeScope")
    @Override
    public ObjectResult countTimeScope(@RequestBody Map<String, Object> map) {
        return commissionService.countTimeScope(map);
    }

    /**
     * 当前登录人下级代理日佣金商户佣金统计，包含自己的直属商户
     * @param commissionCommercialDayRequest
     * @return
     */
    @PostMapping("/findByTimeAndAgentId")
    @Override
    public QueryResponseResult findByTimeAndAgentId(@RequestBody CommissionCommercialDayRequest commissionCommercialDayRequest) {
        return commissionService.findByTimeAndAgentId(commissionCommercialDayRequest);
    }

    /**
     * 根据时间查询当前登录人其下的代理商的商户佣金统计
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findByTimeAndParentAgentId")
    @Override
    public QueryResponseResult findByTimeAndParentAgentId(@RequestBody CommissionRequest commissionRequest) {
        return commissionService.findByTimeAndParentAgentId(commissionRequest);
    }

    /**
     * 当前登录人月佣金统计
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findMouthList")
    @Override
    public QueryResponseResult findMouthList(@RequestBody CommissionRequest commissionRequest) {
        return commissionService.findMouthList(commissionRequest);
    }

    /**
     * 当前登录人月佣金直属商户佣金统计
     * @param map
     * @return
     */
    @PostMapping("/countTimeScopeMonth")
    @Override
    public ObjectResult countTimeScopeMonth(@RequestBody Map<String, Object> map) {
        return commissionService.countTimeScopeMonth(map);
    }

    /**
     * 当前登录人下级代理日佣金商户佣金统计，包含自己的直属商户
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findByTimeAndParentAgentIdMonth")
    @Override
    public QueryResponseResult findByTimeAndParentAgentIdMonth(@RequestBody CommissionRequest commissionRequest) {
        return commissionService.findByTimeAndParentAgentIdMonth(commissionRequest);
    }

    /**
     * 当前登录人下级代理月佣金商户佣金统计，包含自己的直属商户
     * @param commissionCommercialDayRequest
     * @return
     */
    @PostMapping("/findByTimeAndAgentIdMonth")
    @Override
    public QueryResponseResult findByTimeAndAgentIdMonth(@RequestBody CommissionCommercialDayRequest commissionCommercialDayRequest) {
        return commissionService.findByTimeAndAgentIdMonth(commissionCommercialDayRequest);
    }


    /**
     * 根据代理商id和时间查询月佣金
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findByAgentIdAndTimeMonth")
    @Override
    public QueryResponseResult findByAgentIdAndTimeMonth(@RequestBody CommissionRequest commissionRequest) {
        return commissionService.findByAgentIdAndTimeMonth(commissionRequest);
    }

    /**
     * 根据代理商id和时间查询日佣金
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findByAgentIdAndTimeDay")
    @Override
    public QueryResponseResult findByAgentIdAndTimeDay(@RequestBody CommissionRequest commissionRequest) {
        return commissionService.findByAgentIdAndTimeDay(commissionRequest);
    }

    /**
     * 根据id查询月佣金
     * @param id
     * @return
     */
    @GetMapping("/findMonthById/{id}")
    @Override
    public ObjectResult findMonthById(@PathVariable("id") String id) {
        return commissionService.findMonthById(id);
    }

    /**
     * 根据id修改月佣金
     * @param id
     * @param commissionMonth
     * @return
     */
    @PostMapping("/updateMonthById/{id}")
    @Override
    public ResponseResult updateMonthById(@PathVariable("id") String id, @RequestBody CommissionMonth commissionMonth) {
        return commissionService.updateMonthById(id,commissionMonth);
    }
    /**
     * 下级代理商月佣金查看
     * @param page
     * @param size
     * @param commissionRequest
     * @return
     */
    @PostMapping("/findListNotStatus/{page}/{size}")
    @Override
    public QueryResponseResult findListNotStatus(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody CommissionRequest commissionRequest) {
        return commissionService.findListNotStatus(page,size,commissionRequest);
    }
}
